package com.wzdigit.wms.basic.enums;

import com.fasterxml.jackson.annotation.JsonFormat;

import java.util.HashMap;
import java.util.Map;
import java.util.Objects;

/**
 * 拣货任务状态
 * @author yangdongjie
 * @GdnDtlStatusEnum.java
 * @2021年2月23日下午1:54:19
 */
@JsonFormat(shape = JsonFormat.Shape.OBJECT)
//public enum PicktaskStatusEnum implements BaseEnum{
public enum PicktaskFlagEnum {

	UN_CREATED(0, "未生成", "拣货任务标识"),
	ALREADY_CREATED(1, "已生成", "拣货任务标识"),
	PART_CREATED(2, "部分已生成", "拣货任务标识");

	/**
	 * 枚举值
	 */
	public int code;

	/**
	 * 枚举名称
	 */
	public String enumName;

	/**
	 * 枚举实体类属性描述
	 *
	 * @return
	 */
	public String description;


	PicktaskFlagEnum(String enumName, String description) {
		this.enumName = enumName;
		this.description = description;
	}

	PicktaskFlagEnum(int code, String enumName, String description) {
		this.code = code;
		this.enumName = enumName;
		this.description = description;
	}

	public int getCode() {
		return code;
	}

	public void setCode(int code) {
		this.code = code;
	}

	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public static PicktaskFlagEnum getEnumByCode(int enumCode) {
		PicktaskFlagEnum[] values = PicktaskFlagEnum.values();
		PicktaskFlagEnum samplingEnum = null;

		for (PicktaskFlagEnum value : values) {
			if (value.getCode() == enumCode) {
				samplingEnum = value;
			}
		}
		return samplingEnum;
	}

	public static PicktaskFlagEnum getEnumByName(String enumName) {
		PicktaskFlagEnum[] values = PicktaskFlagEnum.values();
		PicktaskFlagEnum repairEnum = null;

		for (PicktaskFlagEnum value : values) {
			if (value.getEnumName() == enumName) {
				repairEnum = value;
			}
		}
		return repairEnum;
	}

	public String getEnumName() {
		return enumName;
	}

	public void setEnumName(String enumName) {
		this.enumName = enumName;
	}

	public static Map<Integer, String> getEnumByDescription() {
		Map<Integer, String> enumMap = new HashMap<>();

		PicktaskFlagEnum[] values = PicktaskFlagEnum.values();
		for (PicktaskFlagEnum value : values) {
			enumMap.put(value.getCode(), value.getEnumName());
		}
		return enumMap;
	}

	public static Map<Integer, String> getEnumByDescription(String enumDescription) {
		Map<Integer, String> enumMap = new HashMap<>();

		PicktaskFlagEnum[] values = PicktaskFlagEnum.values();
		for (PicktaskFlagEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)) {
				enumMap.put(value.getCode(), value.getEnumName());
			}
		}
		return enumMap;
	}

	public static Integer getCodeByEnumNameAndDescription(String enumName, String enumDescription) {
		PicktaskFlagEnum[] values = PicktaskFlagEnum.values();
		for (PicktaskFlagEnum value : values) {
			if (Objects.equals(value.getDescription(), enumDescription)
					&& Objects.equals(value.getEnumName(), enumName)) {
				return value.getCode();
			}
		}
		return null;
	}
}
